#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int n = 0;
    cin >> n;
    vector<int> arr;
    arr.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    vector<int> dp;
    dp.resize(n + 1);
    dp[0] = 0, dp[1] = 0;
    for (int i = 2; i <= n; i++)
    {
        dp[i] = min(dp[i - 1] + arr[i - 1], dp[i - 2] + arr[i - 2]);
    }
    cout << dp[n];

}